home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Controls
/
Visual Basic Controls.iso
/
vbcontrol
/
slock
/
slockfrm.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-08-22
|
28KB
|
514 lines
unit Slockfrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, registry, RegFrm, Slock, ExtCtrls, Menus;
type
TfrmMain = class(TForm)
btnRegister: TButton;
Slock1: TSlock;
grpStatus: TGroupBox;
lblStatus: TLabel;
lblStatusDisp: TLabel;
lblDaysLeft: TLabel;
lblDaysLeftDisp: TLabel;
lblStartsLeftDisp: TLabel;
lblExpiryDateDisp: TLabel;
lblProtType: TLabel;
lblProtTypeDisp: TLabel;
lblStartsLeft: TLabel;
lblExpiryDate: TLabel;
lblRegisteredTo: TLabel;
lblRegisteredToDisp: TLabel;
bvlStatus: TBevel;
lblGraceStartsLeft: TLabel;
lblGraceStartsLeftDisp: TLabel;
mnuMainMenu: TMainMenu;
mnmFile: TMenuItem;
mnpExit: TMenuItem;
mnmRegister: TMenuItem;
mnpRegNow: TMenuItem;
mnmFunction: TMenuItem;
mnpNormFunc: TMenuItem;
btnExit: TButton;
btnDelete: TButton;
procedure Slock1FirstStart(Sender: TObject);
procedure Slock1ClockMovedBack(Sender: TObject);
procedure Slock1Reminder(Sender: TObject);
procedure Slock1WrongUnlockCode(Sender: TObject);
procedure Slock1Expired(Sender: TObject);
procedure btnRegisterClick(Sender: TObject);
procedure Slock1Register(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Slock1RegInfoChanged(Sender: TObject);
procedure Slock1InGracePeriod(Sender: TObject);
procedure Slock1RegWriteErr(Sender: TObject);
procedure mnpNormFuncClick(Sender: TObject);
procedure mnpExitClick(Sender: TObject);
procedure mnpRegNowClick(Sender: TObject);
procedure btnExitClick(Sender: TObject);
procedure Slock1Extend(Sender: TObject);
procedure Slock1TimedOut(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure Slock1RegInfoTamper(Sender: TObject);
private
procedure UpdateStatus;
end;
var
frmMain: TfrmMain;
implementation
(* ToDo:
Delete should also delete DLL Info
tidy up the starts properties (why do we need more than startsleft and graceleft? *)
{$R *.DFM}
{*******************************************************************************
* Procedure : btnRegisterClick *
********************************************************************************
* Purpose : Opens up the window in which the registration information can *
* be entered into *
********************************************************************************
* Paramters : None *
********************************************************************************
* Returns : None *
*******************************************************************************}
procedure TfrmMain.btnRegisterClick(Sender: TObject);
var
frmRegister: TfrmRegister;
begin
// create the registration window
frmRegister := TfrmRegister.Create(self);
// set the caption and show the window
frmRegister.Caption := 'Register ' + Caption;
frmRegister.ShowModal;
// release the window
frmRegister.Free;
// Update the status
UpdateStatus;
end; {btnRegisterClick}
{*******************************************************************************
* Procedure : FormCreate *
********************************************************************************
* Purpose : We check the current status of the protection in the form create *
* of the main form. (Slock1.CheckProtection) The internal state of *
* Slock is set, and we then use 'UpdateStatus' to read the status *
* of Slock out into the status display *
********************************************************************************
* Paramters : None *
********************************************************************************
* Returns : None *
*******************************************************************************}
procedure TfrmMain.FormCreate(Sender: TObject);
begin
// check the protection of the Slock component
SLock1.CheckProtection;
// Update the status display and the state of the Buttons/Menupoints
UpdateStatus;
end; {FormCreate}
{*******************************************************************************
* Procedure : UpdateStatus *
********************************************************************************
* Purpose : Loads the internal status of the Slock component into the status *
* display. Also sets the state of the menus and buttons *
********************************************************************************
* Paramters : None *
********************************************************************************
* Returns : None *
*******************************************************************************}
procedure TfrmMain.UpdateStatus;
begin
// load the status display
case Slock1.Status of
stNotExpired:
lblStatusDisp.Caption := 'Not Expired';
stExpired:
lblStatusDisp.Caption := 'Expired';
stGrace:
lblStatusDisp.Caption := 'Grace Period';
stRegistered:
lblStatusDisp.Caption := 'Registered';
end;
// load the days/starts left display
case Slock1.ProtectionType of
ptStartCount:
begin
lblProtTypeDisp.Caption := 'Start Count';
lblDaysLeftDisp.Caption := 'N/A';
lblStartsLeftDisp.Caption := IntToStr(Slock1.TrialPeriod);
lblGraceStartsLeftDisp.Caption := IntToStr(Slock1.GracePeriod);
lblExpiryDateDisp.Caption := 'N/A';
end;
ptDayCount:
begin
lblProtTypeDisp.Caption := 'Day Count';
lblDaysLeftDisp.Caption := IntToStr(Slock1.TrialPeriod);
lblStartsLeftDisp.Caption := 'N/A';
lblGraceStartsLeftDisp.Caption := IntToStr(Slock1.GracePeriod);
lblExpiryDateDisp.Caption := DateToStr(Slock1.ExpiryDate);
end;
ptExpiryDate:
begin
lblProtTypeDisp.Caption := 'Expiry Date';
lblDaysLeftDisp.Caption := 'N/A';
lblStartsLeftDisp.Caption := 'N/A';
lblGraceStartsLeftDisp.Caption := IntToStr(Slock1.GracePeriod);
lblExpiryDateDisp.Caption := DateToStr(Slock1.ExpiryDate);
end;
ptTimed:
begin
lblProtTypeDisp.Caption := 'Timed';
lblDaysLeftDisp.Caption := 'N/A';
lblStartsLeftDisp.Caption := 'N/A';
lblGraceStartsLeftDisp.Caption := 'N/A';
lblExpiryDateDisp.Caption := 'N/A';
end;
ptDaysUsed:
begin
lblProtTypeDisp.Caption := 'Days Used';
lblDaysLeftDisp.Caption := 'N/A';
lblStartsLeftDisp.Caption := IntToStr(Slock1.TrialPeriod);
lblGraceStartsLeftDisp.Caption := IntToStr(Slock1.GracePeriod);
lblExpiryDateDisp.Caption := 'N/A';
end;
end;
// load the registration information
if Slock1.Registered then
begin
lblRegisteredToDisp.Caption := Slock1.RegName;
end
else
begin
lblRegisteredToDisp.Caption := 'N/A';
end;
// set the state of the buttons/menus
btnRegister.Enabled := not Slock1.Registered;
mnmRegister.Enabled := not Slock1.Registered;
mnmFunction.Enabled := (Slock1.